import { defineStore } from 'pinia'
export const useAppStore = defineStore({
  // id 是必填的，并且所有 Store 中唯一。因为Pinia会将它在devtools显示
  id: 'AppStore',
  state: () => ({
    theme: {
      color: '#7460ee',
      'background-color': '#dcdfe6',
      'border-color': '#dcdfe6',
    },
    layout: {
      asideShow: true,
    },
  }),
  /**
   * 用来封装计算属性 有缓存功能  类似于computed
   */
  getters: {},
  /**
   * 编辑业务逻辑  类似于methods
   */
  actions: {
    GET_DEFAULT: function () {
      return {
        theme: {
          color: '#7460ee',
        },
        layout: {
          menuActive: true,
          asideShow: true,
        },
      }
    },
    SET_THEME(theme: any) {
      this.theme = theme
    },
    GET_THEME: function () {
      return this.theme
    },
    SET_LAYOUT: function (layout: any) {
      this.layout = layout
    },
    GET_LAYOUT: function () {
      return this.layout
    },
    SET_CONFIG: function (config: any) {
      this.theme = config.theme
      this.layout = config.layout
    },
    GET_CONFIG: function () {
      return { layout: this.layout, theme: this.theme }
    },
  },
})
